<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增计划可控费用')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>
    <style>
        input{

            box-shadow: inset 0 2px 2px rgba(0,0,0,.075) !important;
            border-radius: 5px !important;

        }
        select{
            outline: none !important;

        }

    </style>
</head>
<body>
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-controlcost-add">
        <div class="form-group">
            <label class="col-sm-3 control-label ">项目名称：</label>
            <div class="col-sm-8">
                <select id="jspmNo" name="jspmNo" class="form-control" required>
                    <option value="0"></option>
                    <option th:each="fomation:${fomation}" th:value="${fomation.id }"
                            th:text="${fomation.jspmName }"></option>
                </select></div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">计划可控费用：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="planControlcost" id="planControlcost" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">年：</label>
            <div class="col-sm-8">
                <!--<input class="form-control" oninput = "value=value.replace(/[^\d]/g,'')" type="text" name="year" id="year" required>-->
                <select class="form-control" >
                    <option value=""></option>
                    <option value="2018">2018</option>
                    <option value="2019">2019</option>
                    <option value="2020">2020</option>
                </select>

            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">月：</label>
            <div class="col-sm-8">
                <!--<input class="form-control" oninput = "value=value.replace(/[^\d]/g,'')" type="text" name="month" id="month" required>-->
                <select class="form-control">
                    <option value=""></option>
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                    <option value="4">4</option>
                    <option value="5">5</option>
                    <option value="6">6</option>
                    <option value="7">7</option>
                    <option value="8">8</option>
                    <option value="9">9</option>
                    <option value="10">10</option>
                    <option value="11">11</option>
                    <option value="12">12</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">备注：</label>
            <div class="col-sm-8">
                <input class="form-control"  type="text" name="remarks" id="remarks">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">比例：</label>
            <div class="col-sm-8">
                <input class="form-control"  type="text" name="proportion" id="proportion">
            </div>
        </div>
    </form>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: datetimepicker-js"/>

<script type="text/javascript">
    var prefix = ctx + "jianshe/plancontrolcost";

    function submitHandler() {
        if ($.validate.form()) {
            add();
        }
    }

    function add() {
        var jspmNo = $("#jspmNo").val();
        if(jspmNo == 0){
            $.modal.alertWarning('请选择项目！')
            return;
        }
        if($("#month").val()===""){

            $.modal.alertWarning('请选择月！')
            return ;
        }
        if($("#year").val()===""){

            $.modal.alertWarning('请选择年！')
            return ;
        }
        var planControlcost = $("#planControlcost").val();
        var year = $("#year").val();
        var month = $("#month").val();
        var remarks = $("#remarks").val();
        var proportion = $("#proportion").val();

        if ($.validate.form()) {
            var data = $("#form-controlcost-add").serializeArray();
            data.push({"id": "jspmNo", "value": jspmNo});
            data.push({"id": "planControlcost", "value": planControlcost});
            data.push({"id": "year", "value": year});
            data.push({"id": "month", "value": month});
            data.push({"id": "remarks", "value": remarks});
            data.push({"id": "proportion", "value": proportion});
            $.operate.save(prefix + "/add", data);
        }
    }
</script>

</body>
</html>
